package org.example.booksystem.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.booksystem.moudel.BookInfo;
import org.example.booksystem.moudel.PageRequest;

import java.util.List;

@Mapper
public interface BookInfoMapper {

    @Select("select id,book_name,author,count,price,publish,status from book_info where `status` != 0")
    List<BookInfo> getList();

    @Insert("insert into book_info(book_name , author , count ,price , publish , status) values (" +
            "#{bookName}, #{author} , #{count} , #{price},#{publish},#{status} )")
    Integer addBook(BookInfo bookInfo);



    @Select("select count(*) from book_info where status<>0")
    Integer count();

    @Select("select id,book_name,author,count,price,publish,status from book_info  where `status` != 0 " +
            " limit #{pageSize} offset #{offset} ")
    List<BookInfo> getBookListByPage( PageRequest pageRequest);
 
    @Select("select id,book_name,author,count,price,publish,status from book_info where id=#{id};")
    BookInfo getBookById(@Param("id") Integer bookId);

     Integer updateBook(BookInfo bookInfo);


    Integer batchDelete(List<Integer> ids);
}
